<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="description" content="">
<meta name="author" content="ThemeBucket">
<link rel="shortcut icon" type="image/x-icon"
	href="${ctxPath}/static/images/lukk.ico" media="screen" />
<link rel="icon" href="${ctxPath}/static/images/lukk.ico"
	type="image/x-icon" />
<link rel="bookmark" href="${ctxPath}/static/images/lukk.ico"
	type="image/x-icon" />

<title>管理页面</title>
</head>
<body class="sticky-header"
	onload="indexmenu('${oneMenu}','${twoMenu}');">
	<%@ include file="../index/index.jsp"%>
	<section>
		<div class="main-content" style="overflow-y: auto">
			<!-- 地址栏-->
			<div class="page-heading">
				<h3>鹿客帮</h3>
				<ul class="breadcrumb">
					<li><a>订单管理 </a></li>
					<li class="active">安装订单</li>
				</ul>
			</div>
			<div class="panel-body" style="padding-bottom: 0px;">
				<div class="panel panel-default">
					<div class="panel-heading">查询条件</div>
					<div class="panel-body" style="height: 65px">
						<form id="formSearch" class="form-horizontal">
							<input type="hidden" id="queryForm" value="disable">
							<div class="form-group" style="">
								<div class="form-inline col-md-3">
									状态： <select id="indentStatusSelect" name=""
										class="selectpicker show-tick form-control"
										style="width: 120px" data-live-search="false">
										<option value="-2">未选择</option>
										<option value="-1">全部</option>
										<option value="0">未接单</option>
										<option value="4">未付款</option>
										<option value="1">已接单</option>
										<option value="5">已出发</option>
										<option value="2">已完成</option>
										<option value="3">已购买</option>
										<option value="6">已终止</option>
										<option value="7">已取消</option>
									</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;订单ID： <input type="text"
										class="form-control" style="width: 100px"
										id="txt_search_indentID">
								</div>
								<div class="form-inline col-md-2">
									发出人手机：<input type="text" class="form-control"
										id="txt_search_phoneNumber" style="width: 130px">
								</div>
								<div class="form-inline col-md-2">
									发出人姓名：<input type="text" class="form-control"
										style="width: 130px" id="txt_search_merchantName">
								</div>
								<div class="form-inline col-md-4">
									时间段：&nbsp;&nbsp;<input size="" type="text" style="width: 170px"
										class="form_datetime-adv form-control" readonly id="beginTime">
									&nbsp;&nbsp;&nbsp; 到：<input size="" style="width: 170px"
										type="text" readonly class="form_datetime-adv form-control"
										id="endTime">
								</div>
								<div class="form-inline col-md-1" style="text-align: left;">
									<button type="button" style="margin-left: 50px" id="btn_query"
										class="btn btn-primary">查询</button>
								</div>
							</div>
						</form>
					</div>
				</div>
				<div id="toolbar" class="btn-group">
					<label style="color: green">
						&nbsp;&nbsp;&nbsp;&nbsp;注释：支付总价=商人订单价+悬赏钱数，商人订单价=订单价+安心保价钱。只有已完成订单才能填写补差价申请。</label>
				</div>
				<table id="tb_installIndent"></table>
			</div>
		</div>
	</section>
	<!--  查看接单师傅的详细modal  -->
	<div class="modal fade" style="top: 60px; height: 1000px"
		id="viewWorkerDetialModal" tabindex="-1" role="dialog"
		aria-labelledby="viewWorkerDetialModalLabel" aria-hidden="true">
		<div class="modal-dialog" style="width: 1000px; height: 1000px">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="viewWorkerDetialModalLabel">查看师傅的详细信息</h4>
				</div>
				<div class="modal-body">
					<form class="form-horizontal" id="modifyPotentialWorkerForm"
						role="form">
						<input type="hidden" name="id" id="txt_workerID">
						<div class="form-group">
							<label for="txt_phoneNumber" class="col-md-2 control-label">工人头像</label>
							<div class="col-md-4">
								<img src="" id="workerImg" alt="Cinque Terre">
							</div>
							<div class="col-md-6">
								<div role="div">
									<div class="form-group">
										<label for="txt_workerName" class="col-md-4 control-label">师傅名称：</label>
										<div class="col-md-7">
											<input type="text" class="form-control" id="txt_workerName">
										</div class="col-md-1">
										<div></div>
									</div>
									<div class="form-group">
										<label for="txt_workerPhone" class="col-md-4 control-label">师傅手机：</label>
										<div class="col-md-7">
											<input type="text" class="form-control" id="txt_workerPhone">
										</div class="col-md-1">
										<div></div>
									</div>
									<div class="form-group">
										<label for="txt_workerAge" class="col-md-4 control-label">师傅工龄：</label>
										<div class="col-md-7">
											<input type="text" class="form-control" id="txt_workerAge">
										</div class="col-md-1">
										<div></div>
									</div>
									<div class="form-group">
										<label for="txt_workerSpace" class="col-md-4 control-label">师傅所在市：</label>
										<div class="col-md-7">
											<input type="text" class="form-control" id="txt_workerSpace">
										</div class="col-md-1">
										<div></div>
									</div>
									<div class="form-group">
										<label for="txt_workerSpaceArea"
											class="col-md-4 control-label">工作区域：</label>
										<div class="col-md-7">
											<textarea class="form-control" id="txt_workerSpaceArea"
												rows="5"></textarea>
										</div class="col-md-1">
										<div></div>
									</div>
								</div>
							</div>
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭
					</button>
				</div>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal -->
	</div>
	<!--  查询需要取货地址的详情modal  -->
	<div class="modal fade" style="top: 300px;" id="viewTakingAddressModal"
		tabindex="-1" role="dialog"
		aria-labelledby="viewTakingAddressModalOpenLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="viewTakingAddressModalOpenLabel">查看取货的详细信息</h4>
				</div>
				<div class="modal-body">
					<form class="form-horizontal" id="" role="form">
						<div class="form-group">
							<label for="txt_takingGoodsPhone" class="col-md-2 control-label">取货电话</label>
							<div class="col-md-10">
								<input type="text" class="form-control"
									id="txt_takingGoodsPhone">
							</div>
						</div>
						<div class="form-group">
							<label for="txt_takingGoodsAddress"
								class="col-md-2 control-label">取货地址</label>
							<div class="col-md-10">
								<input type="text" class="form-control"
									id="txt_takingGoodsAddress">
							</div>
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭
					</button>
				</div>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal -->
	</div>
	<!--  查看顾客的详细modal  -->
	<div class="modal fade" style="top: 300px;" id="viewInstallPartsModal"
		tabindex="-1" role="dialog"
		aria-labelledby="viewInstallPartsModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="viewInstallPartsModalLabel">查看安装配件的详细信息</h4>
				</div>
				<div class="modal-body">
					<form class="form-horizontal" id="" role="form">
						<div class="form-group">
							<label for="txt_repairPartsMotorNum"
								class="col-md-3 control-label">电机数量：</label>
							<div class="col-md-6">
								<input type="text" class="form-control"
									id="txt_repairPartsMotorNum">
							</div>
							<div class="col-md-3"></div>
						</div>
						<div class="form-group">
							<label for="txt_repairPartsSizhuagouNum"
								class="col-md-3 control-label">四抓钩数量：</label>
							<div class="col-md-6">
								<input type="text" class="form-control"
									id="txt_repairPartsSizhuagouNum">
							</div>
							<div class="col-md-3"></div>
						</div>
						<div class="form-group">
							<label for="txt_repairPartsBigouNum"
								class="col-md-3 control-label">壁钩数量：</label>
							<div class="col-md-6">
								<input type="text" class="form-control"
									id="txt_repairPartsBigouNum">
							</div>
						</div>
						<div class="col-md-3"></div>
					</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭
					</button>
				</div>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal -->
	</div>
	<!--  查看顾客的详细modal  -->
	<div class="modal fade" style="top: 100px;"
		id="viewCustomerDetialModal" tabindex="-1" role="dialog"
		aria-labelledby="viewCustomerDetialModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="viewCustomerDetialModalLabel">查看顾客的详细信息</h4>
				</div>
				<div class="modal-body">
					<form class="form-horizontal" id="" role="form">
						<div class="form-group">
							<label for="txt_customerName" class="col-md-2 control-label">顾客名称</label>
							<div class="col-md-10">
								<input type="text" class="form-control" id="txt_customerName">
							</div>
						</div>
						<div class="form-group">
							<label for="txt_customerPhoneNumber"
								class="col-md-2 control-label">顾客手机</label>
							<div class="col-md-10">
								<input type="text" class="form-control"
									id="txt_customerPhoneNumber">
							</div>
						</div>
						<div class="form-group">
							<label for="txt_customerAddress" class="col-md-2 control-label">顾客地址</label>
							<div class="col-md-10">
								<textarea rows="2" id="txt_customerAddress" class="form-control"></textarea>
							</div>
						</div>
						<div class="form-group">
							<label for="txt_customerRemark" class="col-md-2 control-label">添加备注</label>
							<div class="col-md-10">
								<textarea rows="2" id="txt_customerRemark" class="form-control"></textarea>
							</div>
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭
					</button>
				</div>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal -->
	</div>
	<!-- 查看信息 -->
	<div class="modal fade" style="top: 10px;"
		id="viewIndentGoodPartsModal" tabindex="-1" role="dialog"
		aria-labelledby="viewIndentGoodPartsModalLabel" aria-hidden="true">
		<div class="modal-dialog" style="width: 1200px;">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="viewIndentGoodPartsModalLabel">该订单的所有商品和配件</h4>
				</div>
				<div class="modal-body" style="height: 600px">
					<div class="tabbable tabbable-tabdrop">
						<ul class="nav nav-tabs">
							<li class="active"><a href="#productCurtain"
								data-toggle="tab">成品帘商品</a></li>
							<li><a href="#clothCurtain" data-toggle="tab">布艺帘商品</a></li>
						</ul>
						<div class="tab-content">
							<div class="tab-pane active" id="productCurtain">
								<table id="productCurtainTable">
								</table>
							</div>
							<div class="tab-pane" id="clothCurtain">
								<table id="clothCurtainTable">
								</table>
							</div>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				</div>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal -->
	</div>
	<!--  查看顾客的详细modal  -->
	<div class="modal fade" style="top: 100px;" id="priceSupplementModal"
		tabindex="-1" role="dialog"
		aria-labelledby="priceSupplementModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="priceSupplementModalLabel">补充工人的订单差价</h4>
				</div>
				<div class="modal-body">
					<form class="form-horizontal" id="priceSupplementForm" role="form">
						<input type="hidden" id="txt_merchantSupplementID"
							name="merchantID"> <input type="hidden"
							id="txt_workerSupplementID" name="workerID"> <input
							type="hidden" id="txt_supplementIndentID" name="indentID">
						<div class="form-group">
							<label for="txt_merchantSupplementName"
								class="col-md-3 control-label">需加价商户姓名：</label>
							<div class="col-md-7">
								<input type="text" class="form-control"
									id="txt_merchantSupplementName">
							</div>
							<div class="col-md-2"></div>
						</div>
						<div class="form-group">
							<label for="txt_merchantSupplementPhoneNumber"
								class="col-md-3 control-label">需加价商户手机：</label>
							<div class="col-md-7">
								<input type="text" class="form-control"
									id="txt_merchantSupplementPhoneNumber">
							</div>
							<div class="col-md-2"></div>
						</div>
						<div class="form-group">
							<label for="txt_workerSupplementName"
								class="col-md-3 control-label">加价工人姓名：</label>
							<div class="col-md-7">
								<input type="text" class="form-control"
									id="txt_workerSupplementName">
							</div>
							<div class="col-md-2"></div>
						</div>
						<div class="form-group">
							<label for="txt_workerSupplementPhoneNumber"
								class="col-md-3 control-label">加价工人手机：</label>
							<div class="col-md-7">
								<input type="text" class="form-control"
									id="txt_workerSupplementPhoneNumber">
							</div>
							<div class="col-md-2"></div>
						</div>
						<div class="form-group">
							<label for="txt_workerSupplementMoney"
								class="col-md-3 control-label">加价钱数：</label>
							<div class="col-md-7">
								<input type="text" name="moreMoney" class="form-control"
									onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')"
									id="txt_workerSupplementMoney">
							</div>
							<div class="col-md-2"></div>
						</div>
						<div class="form-group">
							<label for="txt_customerSupplementRemark"
								class="col-md-3 control-label">补充差价事由：</label>
							<div class="col-md-7">
								<textarea rows="4" name="cause" class="form-control"></textarea>
							</div>
							<div class="col-md-2"></div>
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-warning"
						onclick='payMoreMoneySubmit()'>确定</button>
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭
					</button>
				</div>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal -->
	</div>
</body>
<script type="text/javascript"
	src="${ctxPath}/static/js/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
<!--pickers initialization-->
<script
	src="${ctxPath}/static/js/bootstrap-datetimepicker/pickers-init.js"></script>
<!-- tables插件的引用 -->
<script src="${ctxPath}/static/js/bootstrap-table/bootstrap-table.js"></script>
<link href="${ctxPath}/static/js/bootstrap-table/bootstrap-table.css"
	rel="stylesheet" />
<script
	src="${ctxPath}/static/js/bootstrap-table/locale/bootstrap-table-zh-CN.js"></script>

<script type="text/javascript">
	var TableInit = function() {
		var oTableInit = new Object();
		//初始化Table
		oTableInit.Init = function() {
			$('#tb_installIndent')
					.bootstrapTable(
							{
								url : '${ctxPath}/installIndent/queryWorkerIndentByPage', //请求后台的URL（*）
								method : 'post', //请求方式（*）
								toolbar : '#toolbar', //工具按钮用哪个容器
								striped : true, //是否显示行间隔色
								cache : false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
								pagination : true, //是否显示分页（*）
								sortable : false, //是否启用排序
								sortName : 'beginTime',
								sortOrder : "desc", //排序方式
								queryParams : oTableInit.queryParams,//传递参数（*）
								sidePagination : "server", //分页方式：client客户端分页，server服务端分页（*）
								pageNumber : 1, //初始化加载第一页，默认第一页
								pageSize : 10, //每页的记录行数（*）
								pageList : [ 10, 25, 50, 100 ],
								search : false, //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
								strictSearch : false,
								showColumns : false, //是否显示所有的列
								showRefresh : true, //是否显示刷新按钮
								minimumCountColumns : 2, //最少允许的列数
								clickToSelect : false, //是否启用点击选中行
								height : 600, //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
								uniqueId : "indentId", //每一行的唯一标识，一般为主键列
								showToggle : true, //是否显示详细视图和列表视图的切换按钮
								cardView : false, //是否显示详细视图
								detailView : false, //是否显示父子表
								contentType : 'application/x-www-form-urlencoded; charset=UTF-8',
								columns : [
										{
											field : 'indentId',
											title : '订单ID',
											width : '3%',
											align : "center"
										},
										{
											field : 'merchantName',
											title : '发出人名称',
											width : '4%',
											align : "center",
											formatter : function(value, row,
													index) {
												return value + "<br/>("
														+ row.merchantPhone
														+ ")";
											}
										},
										{
											field : 'beginTime',
											title : '下单时间',
											width : '3%',
											align : "center"
										},
										{
											field : 'subscribeTime',
											title : '预约时间',
											width : '3%',
											align : "center"
										},
										{
											field : 'tag3',
											title : '所需商品配件',
											width : '3%',
											align : "center",
											formatter : function(value, row,
													index) {
												return "<button class='btn btn-info btn-xs' onclick='javascript:viewIndentGoodPartsModalOpen("
														+ row.indentId
														+ ")'><font color='green'>查看信息</font></button>";
											}
										},
										{
											field : 'status',
											title : '订单状态',
											width : '4%',
											align : "center",
											formatter : function(value, row,
													index) {
												if (value == 0) {
													return "<font color='red'>未接单</font>";
												} else if (value == 1) {
													return "<font color='green'>已接单</font>";
												} else if (value == 2) {
													return "<font color='green'>已完成</font>";
												} else if (value == 3) {
													return "<font color='green'>已购买</font>";
												} else if (value == 4) {
													return "<font color='red'>未付款</font>";
												} else if (value == 5) {
													return "<font color='green'>已出发</font>";
												} else if (value == 6) {
													return "<font color='green'>已终止</font>";
												} else {
													return "<font color='green'>已取消</font>";
												}
											}
										},
										{
											field : 'workerId',
											title : '接单人信息',
											width : '3%',
											align : "center",
											formatter : function(value, row,
													index) {
												if (row.workerId == null) {
													return "<font color='red'>暂无信息</font>";
												} else {
													return "<button class='btn btn-info btn-xs' onclick='javascript:viewWorkerDetialModalOpen("
															+ value
															+ ")'><font color='green'>查看信息</font></button>";
												}
											}
										},
										{
											field : 'isNeedTakeGoods',
											title : '取货信息',
											width : '3%',
											align : "center",
											formatter : function(value, row,
													index) {
												if (value == 0) {
													return "<font color='red'>暂无信息</font>";
												} else {
													return "<button class='btn btn-info btn-xs' onclick='javascript:viewTakingAddressModalOpen("
															+ row.indentId
															+ ")'><font color='green'>查看信息</font></button>";
												}
											}
										},
										{
											field : 'motorNum',
											title : '配件信息',
											width : '3%',
											align : "center",
											formatter : function(value, row,
													index) {
												if ((value != 0 && value != null)
														|| (row.sizhuagouNum != 0 && row.sizhuagouNum != null)
														|| (row.bigouNum != 0 && row.bigouNum != null)) {
													return "<button class='btn btn-info btn-xs' onclick='javascript:viewInstallPartsModalOpen("
															+ row.indentId
															+ ")'><font color='green'>查看信息</font></button>";
												} else {
													return "<font color='red'>暂无信息</font>";
												}
											}
										},
										{
											field : 'addPrice',
											title : '悬赏价（元）',
											width : '4%',
											align : "center",
										},
										{
											field : 'merchantsPrice',
											title : '订单详情价（元）',
											width : '8%',
											align : "center",
											formatter : function(value, row,
													index) {
												var totalPrice = value;
												return "（商）"
														+ value
														+ ","
														+ "（工）"
														+ row.indentPrice
														+ "<br/>"
														+ "支付总价"
														+ (totalPrice + row.addPrice);
											}
										},
										{
											field : 'relievedBao',
											title : '安心保',
											width : '4%',
											align : "center",
											formatter : function(value, row,
													index) {
												if (value == 1) {
													return "<font color='green'>已购买</font>";
												} else {
													return "<font color='red'>未购买</font>";
												}
											}
										},
										{
											field : 'customerInfo.name',
											title : '顾客姓名',
											width : '4%',
											align : "center"
										},
										{
											field : 'tag',
											title : '顾客信息',
											width : '4%',
											align : "center",
											formatter : function(value, row,
													index) {
												return "<button class='btn btn-info btn-xs' onclick='javascript:viewCustomerDetialModalOpen("
														+ row.indentId
														+ ")'>查看顾客信息</button>";
											}
										},
										{
											field : 'tag2',
											title : '补差价申请',
											width : '6%',
											align : 'center',
											formatter : function(value, row,
													index) {
												if (row.status != 2
														|| row.status == null) {
													return "<font color = 'red'>无法申请</font>";

												} else {
													return "<button  onclick='priceSupplementModalOpen("
															+ row.indentId
															+ ")' class='btn btn-success btn-xs'>补差价申请</button>";
												}
											}
										},{
											field : 'tag3',
											title : '订单操作',
											width : '15%',
											formatter : function(value, row,
													index) {
												if (row.status != 1
														&& row.status != 5) {
													return "&nbsp;&nbsp;&nbsp;<button  onclick='shutdownIndent("
															+ row.indentId
															+ ")' class='btn btn-danger btn-xs'>终止订单</button>";

												} else {
													return "&nbsp;&nbsp;&nbsp;<button onclick='shutdownIndent("
															+ row.indentId
															+ ")' class='btn btn-danger btn-xs'>终止订单</button>&nbsp;&nbsp;&nbsp;<button  onclick='reAllocateIndent("
															+ row.indentId
															+ ")' class='btn btn-success btn-xs'>重新派单</button>";
												}
											}
										}, ]
							});
		};

		//得到查询的参数
		oTableInit.queryParams = function(params) {
			var temp = { //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
				limit : params.limit, //页面大小
				offset : params.offset, //页码
				order : params.order,
				sort : params.sort,
				merchantName : $('#txt_search_merchantName').val(),
				indentStatus : $('#indentStatusSelect').val(),
				phoneNumber : $('#txt_search_phoneNumber').val(),
				beginTime : $("#beginTime").val(),
				endTime : $("#endTime").val(),
				indentID : $('#txt_search_indentID').val()
			};
			return temp;
		};
		return oTableInit;
	};
	function priceSupplementModalOpen(viewID) {
		var indentRow = $('#tb_installIndent').bootstrapTable(
				'getRowByUniqueId', viewID);
		console.info(indentRow);
		$.post('${ctxPath}/worker/queryByPrimaryKey', {
			workerID : indentRow.workerId
		}, function(viewRow) {
			$("#txt_merchantSupplementID").val(indentRow.customerId);
			$("#txt_supplementIndentID").val(indentRow.indentId);
			$("#txt_workerSupplementID").val(indentRow.workerId);
			$("#txt_merchantSupplementName").val(indentRow.merchantName);
			$("#txt_merchantSupplementPhoneNumber")
					.val(indentRow.merchantPhone);
			$("#txt_workerSupplementName").val(viewRow.name);
			$("#txt_workerSupplementPhoneNumber").val(viewRow.phone);
			$("#priceSupplementModal").modal('show');
		});
	}
	function reAllocateIndent(indentID){
		var indentRow = $('#tb_installIndent').bootstrapTable(
				'getRowByUniqueId', indentID);
		$.post('${ctxPath}/cityCostRule/queryCostRuleByWorkerID', {
			workerID : indentRow.workerId
		}, function(viewRow) {
			var indentRow = $('#tb_installIndent').bootstrapTable(
					'getRowByUniqueId', indentID);
			var messageStr = "";
			if (indentRow.status == 5) {
				messageStr = '确定要重新分配该订单吗？？？<br/>订单将会重新推送，已接单工人将会受到扣款'
						+ viewRow.punishClient + '元的惩罚。';
			} else {
				messageStr = '确定要重新分配该订单吗？？？<br/>订单将会重新推送，已接单工人将会受到扣款'
						+ viewRow.punishWorker + '元的惩罚。';
			}
			Ewin.confirm({
				message : messageStr
			}).on(function(e) {
				if (!e) {
					return;
				} else {
					$.post('${ctxPath}/installIndent/reAllocateIndent', {
						workerID : indentRow.workerId,
						indentID : indentID,
						indentStatus : indentRow.status
					}, function(data) {
						var opt = {
							pageNumber : 1,
							query : {
								offset : 0
							}
						};
						//从新开始计数
						$("#tb_installIndent").bootstrapTable('refresh', opt);
						toastr.success("重新拍单成功！");
					});
				}
			});
		})
	}
	function shutdownIndent(indentID) {
		Ewin.confirm({
			message : "您确定要终止该订单吗？？？<br/>终止该订单后师傅和商家将不能针对该订单进行任何操作。"
		}).on(function(e) {
			if (!e) {
				return;
			} else {
				$.post('${ctxPath}/installIndent/updateIndentStatus', {
					indentID : indentID,
					status : 6
				}, function(viewRow) {
					var opt = {

						pageNumber : 1,
						query : {
							offset : 0
						}
					};
					//从新开始计数
					$("#tb_installIndent").bootstrapTable('refresh', opt);
					toastr.success("已经修改成功！");
				});
			}
		});
	}
	function payMoreMoneySubmit() {
		$.post('${ctxPath}/merchantsWalletRecord/payMoreMoneyForIndent', $(
				"#priceSupplementForm").serialize(), function(viewRow) {
			$("#priceSupplementForm")[0].reset();
			$("#priceSupplementModal").modal('hide');
			toastr.success("补差价申请已经申请成功！");
		});
	}
	var ModalTableInit = function() {
		var oModalTableInit = new Object();
		//初始化Table
		oModalTableInit.Init = function() {
			$('#tb_indentGoodParts')
					.bootstrapTable(
							{
								url : '${ctxPath}/installIndent/queryIndentGoodPartsByIndent', //请求后台的URL（*）
								method : 'post', //请求方式（*）
								striped : true, //是否显示行间隔色
								cache : false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
								queryParams : oModalTableInit.queryParams,//传递参数（*）
								sidePagination : "server", //分页方式：client客户端分页，server服务端分页（*）
								search : false, //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
								strictSearch : false,
								showColumns : false, //是否显示所有的列
								showRefresh : false, //是否显示刷新按钮
								minimumCountColumns : 2, //最少允许的列数
								clickToSelect : false, //是否启用点击选中行
								uniqueId : "goodId", //每一行的唯一标识，一般为主键列
								showToggle : false, //是否显示详细视图和列表视图的切换按钮
								cardView : false, //是否显示详细视图
								detailView : false, //是否显示父子表
								pagination : true, //是否显示分页（*）
								sortable : false, //是否启用排序
								contentType : 'application/x-www-form-urlencoded; charset=UTF-8',
								sidePagination : "server", //分页方式：client客户端分页，server服务端分页（*）
								pageNumber : 1, //初始化加载第一页，默认第一页
								pageSize : 12, //每页的记录行数（*）
								pageList : [ 12, 25, 50 ],
								height : 600, //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
								columns : [
										{
											field : 'name',
											title : '员工姓名',
											width : '20%',
											align : "center",
										},
										{
											field : 'phone',
											title : '员工手机',
											width : '20%',
											align : "center",
										},
										{
											field : 'workSpaces',
											title : '员工工作区域',
											width : '60%',
											align : "center",
											formatter : function(value, row,
													index) {
												var returnValue = "";
												$(value)
														.each(
																function(index,
																		currData) {
																	returnValue = returnValue
																			+ " "
																			+ currData.workerSpaceName;
																})
												return returnValue;
											}
										} ],
							});
		};
		//得到查询的参数
		oModalTableInit.queryParams = function(params) {
			var temp = {
				provinceCode : provinceCode,
				limit : params.limit, //页面大小
				offset : params.offset, //页码
				queryType : queryType
			};
			return temp;
		};
		return oModalTableInit;
	};
	//查看待审核员工详细信息
	function viewWorkerDetialModalOpen(id) {
		$.post('${ctxPath}/worker/queryByPrimaryKey', {
			workerID : id
		}, function(viewRow) {
			$("#txt_workerName").val(viewRow.name);
			$("#txt_workerPhone").val(viewRow.phone);
			$("#txt_workerAge").val(viewRow.age);
			$("#txt_workerSpace").val(viewRow.workerSpace);
			var returnValue = "";
			$(viewRow.workSpaces).each(function(index, currData) {
				returnValue = returnValue + " " + currData.workerSpaceName;
			})
			returnValue = returnValue.substring(1);
			$("#txt_workerSpaceArea").val(returnValue);
			$("#workerImg").attr(
					"src",
					"http://okwc9gyzs.bkt.clouddn.com/" + viewRow.headImg
							+ "?imageView2/1/w/350/h/250");
			$('#viewWorkerDetialModal').modal('show');
		});
	}
	//查看那个订单的那个用户
	function viewCustomerDetialModalOpen(id) {
		var viewRow = $('#tb_installIndent').bootstrapTable('getRowByUniqueId',
				id);
		$("#txt_customerName").val(viewRow.customerInfo.name);
		$("#txt_customerPhoneNumber").val(viewRow.customerInfo.phone);
		$("#txt_customerAddress").val(viewRow.customerInfo.customerAddress);
		$("#txt_customerRemark").val(viewRow.remark);
		$('#viewCustomerDetialModal').modal('show');
	}
	//查看那个订单的那个用户
	function viewTakingAddressModalOpen(id) {
		var viewRow = $('#tb_installIndent').bootstrapTable('getRowByUniqueId',
				id);
		$("#txt_takingGoodsPhone").val(viewRow.takeGoodsTel);
		$("#txt_takingGoodsAddress").val(
				viewRow.baseAddress + viewRow.detailAddress);
		$('#viewTakingAddressModal').modal('show');
	}
	function viewInstallPartsModalOpen(id) {
		var viewRow = $('#tb_installIndent').bootstrapTable('getRowByUniqueId',
				id);
		$("#txt_repairPartsMotorNum").val(viewRow.motorNum);
		$("#txt_repairPartsSizhuagouNum").val(viewRow.sizhuagouNum);
		$("#txt_repairPartsBigouNum").val(viewRow.bigouNum);
		$('#viewInstallPartsModal').modal('show');
	}
	function viewIndentGoodPartsModalOpen(id) {
		$.post('${ctxPath}/good/queryIndentProductGoodPartsByIndent', {
			indentID : id
		}, function(data) {
			$('#productCurtainTable').bootstrapTable('load',
					data.productGoodPart);
		});
		$.post('${ctxPath}/good/queryIndentClothGoodPartsByIndent', {
			indentID : id
		}, function(data) {
			$('#clothCurtainTable').bootstrapTable('load', data.clothGoodPart);
		});
		$('#viewIndentGoodPartsModal').modal('show');
	}
	$(function() {
		//1.初始化Table
		var oTable = new TableInit();
		oTable.Init();
		$("#btn_query").click(function() {
			var opt = {

				pageNumber : 1,
				query : {
					offset : 0
				}
			};
			//从新开始计数
			$("#tb_installIndent").bootstrapTable('refresh', opt);
		});
		$('#productCurtainTable').bootstrapTable({
			height : 500,
			columns : [ {
				field : 'goodsId',
				title : '商品ID',
				align : "center"
			}, {
				field : 'type',
				title : '类型',
				align : "center",
				formatter : function(value, row, index) {
					if (value == 0) {
						return "布";
					} else if (value == 1) {
						return "纱";
					} else {
						return "帘头";
					}
				}
			}, {
				field : 'goodForRoom',
				title : '安装房间',
				align : "center"
			}, {
				field : 'window',
				title : '窗户打开方式',
				align : "center"
			}, {
				field : 'pinstallSite',
				title : '安装方式',
				align : "center"
			}, {
				field : 'accessoriesType',
				title : '安装配件',
				align : "center"
			}, {
				field : 'wide',
				title : '宽度（/米）',
				align : "center"
			}, {
				field : 'high',
				title : '高度(/米)',
				align : "center"
			}, {
				field : 'remark',
				title : '备注',
				align : "center"
			} ]
		});
		$('#clothCurtainTable').bootstrapTable({
			height : 500,
			columns : [ {
				field : 'goodsId',
				title : '商品ID',
				align : "center"
			}, {
				field : 'type',
				title : '类型',
				align : "center",
				formatter : function(value, row, index) {
					if (value == 0) {
						return "布";
					} else if (value == 1) {
						return "纱";
					} else {
						return "帘头";
					}
				}
			}, {
				field : 'goodForRoom',
				title : '安装房间',
				align : "center"
			}, {
				field : 'window',
				title : '窗户打开方式',
				align : "center"
			}, {
				field : 'installSite',
				title : '安装位置',
				align : "center"
			}, {
				field : 'decorativeHead',
				title : '装饰头',
				align : "center"
			}, {
				field : 'installWay',
				title : '安装方式',
				align : "center"
			}, {
				field : 'installAaccessries',
				title : '安装配件',
				align : "center"
			}, {
				field : 'accessoriesType',
				title : '（布/纱）配件',
				align : "center"
			}, {
				field : 'wide',
				title : '宽度（/米）',
				align : "center"
			}, {
				field : 'high',
				title : '高度(/米)',
				align : "center"
			}, {
				field : 'remark',
				title : '备注',
				align : "center"
			} ]
		});
	});
</script>
<script src="${ctxPath}/static/js/jquery.nicescroll.js"></script>
</html>
